// pages/list/list.js
Page({

  data: {
    // 定义轮播图图片资源
    img: [
      '../../imgs/b1.jpg',
      '../../imgs/b2.jpg',
      '../../imgs/b3.jpg',
      '../../imgs/b4.jpg',
      '../../imgs/b5.jpg'
    ],
    list:[],
    page:1,
    id:0
  },
  onLoad(options){
    this.data.id = options.classifyId;
    wx.request({
      url: 'https://route.showapi.com/1700-2?showapi_appid=1367085&showapi_sign=cb8507c33e4a43cfa34a954c91b91fd6',
      method:'GET',
      data:{
        classifyId:this.data.id
      },
      header:{'content-type': 'application/json'},
      success:(res)=>{
        console.log(res);
        this.setData({
          list:res.data.showapi_res_body.contentlist,
          id:options.classifyId
        })
      },
      fail:(err)=>{
        console.log(err);
      }
    })
  },
  onReachBottom(){
    this.data.page++
    wx.request({
      url: 'https://route.showapi.com/1700-2?showapi_appid=1367085&showapi_sign=cb8507c33e4a43cfa34a954c91b91fd6',
      method:'GET',
      data:{
        classifyId:this.data.id,
        page:this.data.page
      },
      header:{'content-type': 'application/json'},
      success:(res)=>{
        console.log(res);
        this.setData({
          list:this.data.list.concat(res.data.showapi_res_body.contentlist)
        })
      },
      fail:(err)=>{
        console.log(err);
      }
    })
  },
  godetail(e){
    console.log(e);
    wx.navigateTo({
      url: '../b/b?id=' + e.currentTarget.dataset.id
    })
  }
})